#include "task.h"

struct test_task {
    task_t task;
	int num;
    uint8_t exit_flag;
};

static struct test_task tt;

static void *test_task_func(void *arg)
{
   struct test_task *p_task = (struct test_task *)arg; 
    while(!p_task->exit_flag){
        sleep(1);
        p_task->num += 1;
        printf("num = %u\n", p_task->num);
    }

    return NULL;
}

int task_test(void)
{
    printf("** task test:\n");
	tt.num = 0;
	tt.exit_flag = 0;
    task_init(&tt.task, "test-task", test_task_func, &tt);

    sleep(15);
    tt.exit_flag = 1;
    task_term(&tt.task);
    printf("** task test success\n");
    return 0;
}
